import {post, get, patch, del} from './http';

const CROSS_URL = '/api'; //跨域配置 项目启动地址为： http://127.0.0.2:5000
 const API = {
    // 登录接口
    login (params) {
        return get(`${CROSS_URL}/users`, params)
    },
    // 左侧路由权限
    rights (params) {
        return get(`${CROSS_URL}/rights`, params)
    },
    // 左侧子路由权限
    children (params) {
        return get(`${CROSS_URL}/children`, params)
    },
    // home首页新闻
    news (params) {
        return get(`${CROSS_URL}/news`, params)
    },
    // 区域
    regions (params) {
        return get(`${CROSS_URL}/regions`, params)
    },
    // 角色
    roles (params) {
        return get(`${CROSS_URL}/roles`, params)
    },
    // 切换用户状态
    changeStatus (id, params) {
        return patch(`${CROSS_URL}/users/${id}`, params)
    },
    // 添加用户
    addUser (params) {
        return post(`${CROSS_URL}/users`, params)
    },
    // 删除用户
    delUser (id) {
        // console.log(id)
        return del(`${CROSS_URL}/users/${id}`)
    },
    // 修改用户
    modifyUser (id, params) {
        // console.log(id, params)
        return patch(`${CROSS_URL}/users/${id}`, params)
    },
    // 删除角色
    delRole (id) {
        // console.log(id)
        return del(`${CROSS_URL}/roles/${id}`)
    },
    // 修改角色
    changeRole (id, params) {
        return patch(`${CROSS_URL}/roles/${id}`, params)
    },
    // 删除权限
    delRight (id) {
        // console.log(id)
        return del(`${CROSS_URL}/rights/${id}`)
    },
    changeRight (id, params) {
        return patch(`${CROSS_URL}/rights/${id}`, params)
    },
    changeChildrenRight (id, params) {
        return patch(`${CROSS_URL}/children/${id}`, params)
    },
    // 获取新闻分类
    getCates () {
        return get(`${CROSS_URL}/categories`)
    },
    saveNews (params) {
        return post(`${CROSS_URL}/news`, params)
    },
    // 草稿列表
    getDraft (params) {
        return get(`${CROSS_URL}/news`,params)
    },
    // 删除草稿
    delDraft (id) {
        return del(`${CROSS_URL}/news/${id}`)
    },
    // 预览修改草稿
    modifyDraft (id, params) {
        return get(`${CROSS_URL}/news/${id}`,params)
    },
    // 通过草稿
    passDraft (id ,params) {
        return patch(`${CROSS_URL}/news/${id}`,params)
    },
    // 删除分类
    delCate(id) {
        // console.log(id)
        return del(`${CROSS_URL}/categories/${id}`)
    }
}

export default API;